<?php

session_start();
if(!array_key_exists("user", $_SESSION) || $_SESSION['account'] != 1){
	header("Location: ../common/redirect.php");
	exit;
}

if(!array_key_exists("exam_id", $_POST)){
	header("Location: test.php");
}

include_once("../class/db.php");
$db = new db();

$sql = "SELECT title, question_timer, start_date, end_date, calculator, question_quantity, question_type FROM course_content WHERE id = {$_POST['exam_id']} AND contenttype = 'exam'";
$exam_data = $db->execute($sql, "onerow");

if($exam_data == false){
	header("Location: test.php");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PIE EDUCATION | My Exams</title>
<link rel="stylesheet" type="text/css" href="/css/style-student.css" />
<link href="/css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/index.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script language="Javascript1.2">
<!--
setTimeout('location.href="/logout.php?expire=1"',600000);
// -->
</script>
<script>
	$(document).ready(function() {
		$("#accordion").accordion({ autoHeight: false });
	});
</script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35230372-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#000000"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350" height="30">&nbsp;</td>
        <td align="right" valign="bottom"><a href="class.php" class="top-menu" style="color:#999">MY COURSES</a> <a href="schedule.php" class="top-menu" style="color:#999">CALENDAR</a> <a href="homework.php" class="top-menu" style="color:#999">HOMEWORK</a> <a href="test.php" class="top-menu" style="color:#999">EXAMS</a>  <a href="history.php" class="top-menu" style="color:#999">RECORDS</a> <a href="tools.php" class="top-menu" style="color:#999">TOOLS</a> <a href="/logout.php" class="top-menu" style="color:#999">SIGN OUT</a></td>
      </tr>
	  <tr>
        <td>&nbsp;</td>
        <td align="right" valign="bottom"><a href="/profile/" class="login-menu" style="color:#FFF"><?php echo $_SESSION['name'].' '.$_SESSION['lname']; ?></a> <a href="/common/settings.php" class="login-menu" style="color:#FFF">Change Settings</a> <a href="/common/redirect.php" class="login-menu" style="color:#FFF">My Documents</a> <a href="/network/" class="login-menu" style="color:#FFF">My Network</a></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="30" style="background-image:url(/images/top-bg-student.png); background-repeat:repeat-x">&nbsp;</td>
  </tr>
  <tr>
    <td height="700" valign="top"><form id="take_test_form" name="take_test_form" method="post" action="take_test.php">
      <table width="980" border="0" align="center" cellpadding="4" cellspacing="4">
        <tr>
          <td height="60" align="center" style="font-family:Arial, Helvetica, sans-serif; color:#F00; font-size:18px; font-weight:bold">You are about to take an exam, please read carefully the instructions below before you take the exam</td>
        </tr>
        <tr>
          <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><p>Once you click on &quot;<strong>Confirm and Take the Exam</strong>&quot; your test will start and you can't close your browser or refresh the page until you finish your test. Please note that the use of open books, other browser windows, notes or anything that can provide you the answers are not allowed. You can use a a blank paper and a pencil to make any calculation if needed, in some exams a calculator is provided on the same page. </p>
            <p>Some test are configured to provide at the end of the test your grade. After finish your test you can review your answers on the &quot;<strong>Records</strong>&quot; link in the top of the page, depending on the test configuration this can be available right after you finish your exam or until your teacher provide the grade. You exam has the next details:</p></td>
        </tr>
        <tr>
          <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><ul>
            <li>Test Name: <strong><?php echo $exam_data['title']; ?></strong></li>
            <li>Question Quantity: <strong><?php echo $exam_data['question_quantity']; ?></strong></li>
            <li>Question Type: <strong><?php echo $exam_data['question_type']; ?></strong></li>
            <li>Time to Complete:
              <?php if($exam_data['question_timer'] == 0) { echo "<strong>No Timer</strong>"; } else {echo "<strong>".$exam_data['question_timer']."</strong>"; } ?>
              </li>
            <li>Start Date: <strong>
              <?php 
		  	if($exam_data['start_date'] == "0000-00-00 00:00:00"){
				echo "No Start Date Set";
			} else {

				$dates = explode(" ", $exam_data['start_date']);
				list($year, $month, $day) = explode("-", $dates[0]);
				list($hour, $minute, $second) = explode(":", $dates[1]);
				echo date("d F  H:i", mktime($hour, $minute, $second, $month, $day, $year));
			}
		  ?>
              </strong></li>
            <li>End Date: <strong>
              <?php
		  	if($exam_data['start_date'] == "0000-00-00 00:00:00"){
		  		echo "No End Date Set";
			} else {
				$dates = explode(" ", $exam_data['end_date']);
				list($year2, $month2, $day2) = explode("-", $dates[0]);
				list($hour2, $minute2, $second2) = explode(":", $dates[1]);
				echo date("d F  H:i", mktime($hour2, $minute2, $second2, $month2, $day2, $year2)); 
			}
		  ?>
              </strong></li>
            <li>Calculator Available: <strong><?php echo $exam_data['title']; ?></strong></li>
            <li>Automatic Score: <strong><?php echo $exam_data['title']; ?></strong></li>
            </ul></td>
        </tr>
        <tr>
          <td align="center"><input name="exam_id" type="hidden" id="exam_id" value="<?php echo $_POST['exam_id']; ?>" />
            <input name="button" type="submit" class="submit-center" id="button" value="Confirm and Take the Exam" />
            <a href="test.php" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">Cancel</a></td>
        </tr>
      </table>
    </form></td>
  </tr>
  <tr>
    <td height="30" style=" background-image:url(../images/bottom-bg-student.png); background-repeat:repeat-x;">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center" bgcolor="#000000" style="color:#fff; font-family:Arial, Helvetica, sans-serif">PIE.EDU All Rights Reserved 2012<br />
      <a href="/common/privacy.php" class="bottom-menu" style="color:#999">Privacy Policy</a> | <a href="/common/terms.php" class="bottom-menu"  style="color:#999">Terms of Use</a> | <a href="/help/main.php" class="bottom-menu" style="color:#999">Help Center</a> | <a href="/common/jobs.php" class="bottom-menu" style="color:#999">Jobs</a></td>
  </tr>
</table>
</body>
</html>